/*
 * @Description: 
 * @Autor: 商晓彬
 * @Date: 2021-08-19 11:33:09
 * @LastEditors: 商晓彬
 * @LastEditTime: 2021-12-09 16:10:41
 */
import { LazyLoadEvent } from 'primeng/api';
import { Component, Injector, ViewChild } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { Table } from 'primeng/components/table/table';
import { Paginator } from 'primeng/components/paginator/paginator';
import { MessageService } from '@abp/message/message.service';
import { MoadifManageServiceProxy,BomMakeContentServiceProxy } from '@shared/service-proxies/service-proxies';
import { finalize } from 'rxjs/operators';
import { BomWatchComponent } from './bom-watch/bom-watch.component';
import { BomResumeComponent } from './bom-resume/bom-resume.component';
import { AddBomComponent } from './add-bom/add-bom.component';
@Component({
    selector: 'app-make-bom',
    templateUrl: './make-bom.component.html',
    styleUrls: ['./make-bom.component.less']
})
export class MakeBomComponent extends AppComponentBase {
    @ViewChild('showResume') ShowResume: BomResumeComponent;
    @ViewChild('addBom') AddBom: AddBomComponent;
    @ViewChild('bomWatch') BomWatch: BomWatchComponent;
    @ViewChild('paginator') paginator: Paginator;
    @ViewChild('dataTable') dataTable: Table;
    //2021-10-07 曲冰修改
    materialsNo = undefined;
    materialName = undefined;
    model = undefined;
    sendTime = undefined;
    rowdata: any;//子组件传参
    constructor(
        injector: Injector,
        private _messageService: MessageService,
        private _moadifManageServiceProxy: MoadifManageServiceProxy,
        private _bomMakeContentServiceProxy: BomMakeContentServiceProxy,
    ) {
        super(injector);
    }
    ngOnInit() {
    }
    add() {
        //变更申请
        setTimeout(() => {
            this.AddBom.show();
        }, 10)
    }
    reset() {
        this.model = undefined;
        this.materialName = undefined;
        this.materialsNo = undefined;
        this.sendTime = undefined;
    }
    delete(row) {

    }
    watch(row) {
        this.rowdata = row;
        //履历 
        setTimeout(() => {
            this.BomWatch.show();
        }, 20);
    }
    look(row) {
        this.rowdata = row;
        //履历 
        setTimeout(() => { 
            this.ShowResume.show()
            this.ShowResume.getTableList()
        }, 20);
    }
    getTableList(event?: LazyLoadEvent) {
        if (this.primengTableHelper.shouldResetPaging(event)) {
            this.paginator.changePage(0);
            return;
        }
        this._bomMakeContentServiceProxy.getMakeBomContent(
            //2021-10-07 曲冰添加
            this.model,
            this.materialName,
            this.sendTime,
            this.materialsNo,
            this.primengTableHelper.getSorting(this.dataTable),
            this.primengTableHelper.getMaxResultCount(this.paginator, event),
            this.primengTableHelper.getSkipCount(this.paginator, event)
        ).pipe(finalize(() => this.primengTableHelper.hideLoadingIndicator())).subscribe(result => {
            this.primengTableHelper.totalRecordsCount = result.totalCount;
            this.primengTableHelper.records = result.items;
            this.primengTableHelper.hideLoadingIndicator();
        });
    }

}
